% Creates a probability distribution for the idiosyncratic shock
% + leptokurtik shock
%*************************************************************

function Proba = CreateProba_KR(rho,sigma_eps,a, pa)

agridsize = size(a,1);

a_old = repmat(rho*a,1,agridsize-1);
sigma_eps_matrix = repmat(sigma_eps,agridsize,agridsize-1);

a_j = (a(1:end-1,1)+a(2:end,1))/2;
a_j_matrix = repmat(a_j',agridsize,1);

a_norm = normcdf(a_j_matrix,a_old,sigma_eps_matrix);

a_norm_up = [a_norm ones(agridsize,1)];
a_norm_dwn = [zeros(agridsize,1) a_norm];

Proba = a_norm_up - a_norm_dwn;

Proba = Proba.*(Proba > 10^(-6));
Proba = Proba./(sum(Proba')'*(ones(1,agridsize)));

Proba_p=Proba.*pa;

Proba_1p=eye(agridsize,agridsize).*(1-pa);

Proba=Proba_p+Proba_1p;



